<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="spring" 	uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="tiles" 	uri="http://tiles.apache.org/tags-tiles" %>
<%@ taglib prefix="c"		uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page language="java" pageEncoding="utf-8"%>

<script type="text/javascript">
$(document).ready(function(){
	setMenuSelection("cadouri");
	
    $("#btCadouriList").kendoButton({icon: "funnel"});

    $("#btCadouriCard").kendoButton({icon: "plus"});
    
	
    $("#gridCadouriList").kendoGrid({
    	dataSource : {
            type     : "json",
            transport: {
                read: "stock/stockDocumentList"
            },
            schema   : {
                data: ""
            }
        },
        columns: [
				{
					field:"id",  							
					title: "Nr. document",
					width: 40,
					hidden: false
				},
				{field: "documentData", 					title: "Data Document",			width: 90},
                {field: "stockDocumentType.description", 	title: "Tip Document", 			width: 100},
                {field: "dtUser", 							title: "Debit",					width: 90, template: renderDtUser },
                {field: "ctUser", 							title: "Credit",				width: 90, template: renderCtUser },
                {field: "contracts", 						title: "Nr. Contract", 			width: 120, template: renderContractNr }
          ],
          height: 500,
          sortable: true,
          pageable: {
        	  pageSize: 10,
        	  pageSizes: [10,15,20],
        	  refresh: true
          }

    });    
 
 

});

function  renderDtUser (dataItem) {
	if (dataItem.dtUser) {
		return kendo.htmlEncode(dataItem.dtUser.fullName);
	}
	return kendo.htmlEncode("");
}

function  renderCtUser (dataItem) {
	if (dataItem.ctUser) {
		return kendo.htmlEncode(dataItem.ctUser.fullName);
	}
	return kendo.htmlEncode("");
}

function  renderContractNr (dataItem) {
	if (dataItem.contracts) {
		return kendo.htmlEncode(dataItem.contracts.contractNo);
	}
	return kendo.htmlEncode("");
}


function  renderCompaniesName (dataItem) {
	if (dataItem.regCompanies) {
		return kendo.htmlEncode(dataItem.regCompanies.companyName);
	}
	return kendo.htmlEncode("ZZ");
}

function  renderPersonsName (dataItem, b, c) {
	var result  = "";
	if (dataItem.regPersons) {
		return kendo.htmlEncode( dataItem.regPersons.lastName + " " + dataItem.regPersons.firstName);
	}
	return kendo.htmlEncode("ZZ");
} 	
	
</script>
<CENTER>
<p style="text-align: left;">
	<button id="btCadouriList" type="button" onclick="javascript:window.open('vizualizeazaCadouri', target='_self')";>Lista cadourilor pe stoc 		</button>
	<button id="btCadouriCard" type="button" onclick="javascript:window.open('adaugaСadouri', 	  	target='_self')";>Introducere Operatie Manuala	</button>
	
	<c:if test="${errorMessage != '' &&  errorMessage != '0'}">
		<span id="errorMessage" class="errorMessage"> ${errorMessage} </span>
	</c:if>
	Cadouri Sold Admin 
</p>
<div id="gridCadouriList"></div>

</center>




